<?php

require_once dirname(__FILE__).'/../lib/dynamicinfomationGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/dynamicinfomationGeneratorHelper.class.php';

/**
 * dynamicinfomation actions.
 *
 * @package    nutrition
 * @subpackage dynamicinfomation
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class dynamicinfomationActions extends autoDynamicinfomationActions
{
   /**
   * 执行单一激活任务
   * 
   * @param sfWebRequest $request
   */  
  public function executeListActive(sfWebRequest $request)
  {
    $news = $this->getRoute()->getObject();
    $news->active(true);    
    $this->getUser()->setFlash('notice', '所选的一条记录被成功激活');
    $this->redirect('@dynamicinfomation');
  }
    /**
   * 执行批量激活任务
   * 
   * @param sfWebRequest $request
   */  
  public function executeBatchActive(sfWebRequest $request)
  {
    $ids = $request->getParameter('ids');
 
    $q = Doctrine_Query::create()
      ->from('dynamicinfomation d')
      ->whereIn('d.id', $ids);
 
    foreach ($q->execute() as $news)
    {
      $news->active(true);
    }
 
    $this->getUser()->setFlash('notice', '选择的记录被成功激活');
 
    $this->redirect('@dynamicinfomation');
  }
  /**
   * 执行预览动作
   * 
   * 能获取与该对象的详细信息
   * 
   * @param sfWebRequest $request
   */
  public function executeListPreview(sfWebRequest $request)
  {
      $this->news = $this->getRoute()->getObject();
  }
  public function executeSelect(sfWebRequest $request)
  {
      $this->forward404Unless($request->isMethod(sfRequest::POST));
      $this->forward404Unless($val = $request->getParameter('select_dynamic'));
//      return $this->renderText($val);
        switch ($val){
            case '1':
                return $this->redirect('@dynamicinfomation');
                break;
            case '2':
                return $this->redirect('@dynamicinfomation_school');
                break;
            default :
                return $this->renderText('san');
                break;
        }
  }
}
